<template>
  <view
    class="content"
    :style="{
      'padding-top': height + 'px',
    }"
  >
    <view
      :style="{
        height: statusBarHeight + 'px',
      }"
    >
    </view>
    <view
      class="head"
      :style="{
        top: statusBarHeight + 'px',
      }"
    >
      <view class="head_left">
        <u-icon
          name="arrow-left"
          color="#444444"
          size="24"
          :bold="true"
          @click="toBack"
        ></u-icon>
      </view>
      <view class="text">咨询问道</view>
    </view>

    <view class="box">
      <view class="box_input">
        <view class="box_input_title">姓名</view>
        <u--input
          placeholder="请填写姓名"
          border="none"
          v-model="form.name"
          placeholderStyle="font-size:32rpx;color:#888888;"
          prefixIconStyle="font-size: 32rpx;color: #888888"
          inputAlign="right"
        ></u--input>
      </view>
      <view class="box_input">
        <view class="box_input_title">联系方式</view>
        <u--input
          placeholder="请填写联系方式"
          border="none"
          v-model="form.phone"
          placeholderStyle="font-size:32rpx;color:#888888;"
          prefixIconStyle="font-size: 32rpx;color: #888888"
          inputAlign="right"
        ></u--input>
      </view>
      <view class="box_title">备注</view>
      <u--textarea
        v-model="form.content"
        placeholder="请描述你的重大生命课题……"
        border="bottom"
        height="200"
        placeholderClass="placeholderCss"
      ></u--textarea>

      <view class="bottom">
        <view class="bottom_btn" @click="subFn">提交</view>
      </view>
    </view>
	<floatingBall></floatingBall>
  </view>
</template>
      
      <script>
import selectType from "@/components/selectType.vue";
export default {
  components: {
    selectType,
  },
  data() {
    return {
      statusBarHeight: 0,
      height: 0,
      form: {
        name: "",
        phone: "",
        content:'',
        id:''
      },
    };
  },
  onLoad(options) {
    this.id = options.id;
  },
  created() {
    const statusBarHeight = uni.getSystemInfoSync(); // 获取手机状态栏高度
    this.statusBarHeight = statusBarHeight.statusBarHeight;
    this.$nextTick(() => {
      uni
        .createSelectorQuery()
        .select(".head")
        .boundingClientRect((data) => {
          this.height = data.height;
        })
        .exec();
    });
  },
  methods: {
    toBack() {
      uni.navigateBack({
        delta: 1,
      });
    },
    subFn() {
      //   uni.$u.toast("提交成功，请等待我们的回复");
      if (this.form.name == "") {
        uni.$u.toast("请输入姓名");
        return;
      } else if (this.form.phone == "") {
        uni.$u.toast("请输入联系方式");
        return;
      }
      this.feedback();
    },
    // 咨询提交
    feedback() {
      this.$http
        .yitianForm_submit({
          link_id: this.id,
          name: this.form.name,
          phone: this.form.phone,
          content: this.form.content,
          type: 8,
        })
        .then((res) => {
          console.log(res);
          uni.$u.toast(res.message);
          setTimeout(() => {
            uni.navigateBack({
              delta: 1,
            });
            // uni.reLaunch({
            //   url: `/pages/detail/wenDetail?id=${this.id}`,
            // });
          }, 1000);
        })
        .catch((error) => {
          uni.$u.toast(error);
        });
    },
  },
};
</script>
      
      <style scoped lang="scss">
.content {
  box-sizing: border-box;
}
.head {
  width: 100%;
  padding: 18rpx 30rpx 47rpx;
  position: fixed;
  display: flex;
  justify-content: center;
  align-items: center;
  box-sizing: border-box;
  z-index: 99;
  background: #fff;

  .head_left {
    position: absolute;
    left: 30rpx;
  }

  .head_right {
    position: absolute;
    right: 30rpx;
    display: flex;
  }

  .text {
    font-size: 36rpx;
    font-family: PingFang SC-Bold, PingFang SC;
    font-weight: 400;
    color: #444444;
  }
}
.box {
  padding: 30rpx 0;
  box-sizing: border-box;
  .box_input {
    padding: 32rpx 30rpx;
    box-sizing: border-box;
    border-bottom: 1rpx solid #dadbde;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .box_input_title {
      font-size: 32rpx;
      color: #444444;
      margin-right: 150rpx;
    }
  }
  .box_title {
    padding: 0 30rpx;
    font-size: 32rpx;
    color: #444444;
    margin-top: 32rpx;
  }
  /deep/.u-textarea {
    padding: 0;
    .u-textarea__field {
      padding: 16rpx 30rpx;
    }
  }
  /deep/.uni-textarea-placeholder {
    font-size: 32rpx;
  }

  .bottom {
    position: fixed;
    left: 0;
    bottom: 0;
    width: 100%;
    margin-bottom: 80rpx;
    .bottom_btn {
      width: 630rpx;
      height: 96rpx;
      background: linear-gradient(360deg, #50b674 0%, #aeddbd 100%);
      border-radius: 48rpx;
      text-align: center;
      line-height: 96rpx;
      font-size: 30rpx;
      color: #ffffff;
      margin: 0 auto;
    }
  }
}
</style>